//package com.zmn.plat.dubbo.impl.channel;
//
//import java.util.ArrayList;
//import java.util.List;
//
//import javax.annotation.Resource;
//
//import com.zmn.common.utils.number.NumberUtil;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.dubbo.config.annotation.Service;
//import org.springframework.cache.annotation.Cacheable;
//import org.springframework.cglib.beans.BeanCopier;
//
//import com.zmn.common.dto2.ResponseDTO;
//import com.zmn.manager.common.database.annotation.ReadOnlyConnection;
//import com.zmn.plat.common.dto.channel.ChannelInterfaceDIO;
//import com.zmn.plat.common.dto.channel.ChannelInterfaceDRO;
//import com.zmn.plat.dubbo.interfaces.channel.ChannelInterfaceListRemoteService;
//import com.zmn.plat.dubbo.utils.DubboConsts;
//import com.zmn.plat.model.entity.channel.ChannelInterface;
//import com.zmn.plat.model.entity.channel.ChannelInterfaceQuery;
//import com.zmn.plat.services.interfaces.channel.ChannelInterfaceService;
//import com.zmn.plat.utils.bean.BeanCopyUtils;
//
///**
// * 描述: 渠道类型dubbo接口
// *
// * @author tanghongjun
// * @since: 2018/11/7 17:44
// */
//@Slf4j
//@Service(version = DubboConsts.INTERFACE_VERSION, validation = "true")
//public class ChannelInterfaceListRemoteServiceImpl implements ChannelInterfaceListRemoteService {
//
//    @Resource
//    protected ChannelInterfaceService channelInterfaceService;
//
//    @Override
//    @ReadOnlyConnection
//    @Cacheable(key = "'dubbo:list:channel:interface:id:'+#p0", cacheNames = "redis1h")
//    public ResponseDTO<ChannelInterfaceDRO> getById(Integer interfaceId) {
//        log.info("ChannelInterfaceListRemoteServiceImpl.getById参数interfaceId：{}", interfaceId);
//
//        ChannelInterface channelInterface = channelInterfaceService.findByKey(interfaceId);
//        ChannelInterfaceDRO channelInterfaceDRO = new ChannelInterfaceDRO();
//
//        if (NumberUtil.isNullOrZero(channelInterface.getInterfaceId())) {
//            return ResponseDTO.success(channelInterfaceDRO, "OK");
//        }
//        BeanCopyUtils.copyProperties(channelInterface, channelInterfaceDRO);
//        return ResponseDTO.success(channelInterfaceDRO, "OK");
//    }
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<List<ChannelInterfaceDRO>> listByDIO(ChannelInterfaceDIO channelInterfaceDIO) {
//        log.info("ChannelInterfaceListRemoteServiceImpl.listByDIO参数channelInterfaceDIO：{}", channelInterfaceDIO);
//
//        ChannelInterfaceQuery query = new ChannelInterfaceQuery();
//        BeanCopyUtils.copyProperties(channelInterfaceDIO, query);
//
//        List<ChannelInterface> channelInterfaceList = channelInterfaceService.listByQuery(query);
//
//        return this.listToDRO(channelInterfaceList);
//    }
//
//    @Override
//    @ReadOnlyConnection
//    @Cacheable(key = "'dubbo:list:channel:area:all'", cacheNames = "redis1h")
//    public ResponseDTO<List<ChannelInterfaceDRO>> listAll() {
//        List<ChannelInterface> channelInterfaceList = channelInterfaceService.listAll();
//
//        return this.listToDRO(channelInterfaceList);
//    }
//
//    private ResponseDTO listToDRO(List<ChannelInterface> channelInterfaceList) {
//        List<ChannelInterfaceDRO> items = new ArrayList<>();
//        ChannelInterfaceDRO channelInterfaceDRO;
//        BeanCopier copier = BeanCopier.create(ChannelInterface.class, ChannelInterfaceDRO.class, false);
//        for (int i = 0; i < channelInterfaceList.size(); i++) {
//            channelInterfaceDRO = new ChannelInterfaceDRO();
//            copier.copy(channelInterfaceList.get(i), channelInterfaceDRO, null);
//            items.add(channelInterfaceDRO);
//        }
//
//        return ResponseDTO.success(items);
//    }
//
//}
